# -*- coding: utf-8 -*-
#定义RGB图像转换为HSI图像函数
def rgb2hsi(r,g,b):
    import math 
    import sys
    #归一化处理
    r=r/255
    g=g/255
    b=b/255
    num=0.5*((r-g)+(r-b))
    den=((r-g)*(r-g)+(r-b)*(g-b))**0.5
    if b<=g:
        if den==0:
            den=sys.float_info.min
        h=math.acos(num/den)
    elif b>g:
        if den==0:
            den=sys.float_info.min
        h=(2*math.pi)-math.acos(num/den)
    s=1-(3*min(r,g,b)/(r+g+b))
    i=(r+g+b)/3
    return int(h),int(s*100),int(i*255)
